package software

type T struct {
	Hostname   string `json:"hostname"`
	NodeId     string `json:"node_id"`
	LuaVersion string `json:"lua_version"`
	Plugins    struct {
		AvailableOnServer []interface{} `json:"available_on_server"`
		EnabledInCluster  []interface{} `json:"enabled_in_cluster"`
	} `json:"plugins"`
	Configuration struct {
	} `json:"configuration"`
	Tagline string `json:"tagline"`
	Version string `json:"version"`
}
type T2 struct {
	Message string `json:"message"`
}
type T3 struct {
	Fields []interface{} `json:"fields"`
}
type T4 struct {
	Id struct {
		Type      string `json:"type"` // integer
		Auto      bool   `json:"auto"`
		Uuid      bool   `json:"uuid"`
		Timestamp bool   `json:"timestamp"`
	} `json:"id"`
}
type T5 struct {
	Fields struct {
		HideCredentials struct {
			Default bool   `json:"default"`
			Type    string `json:"type"`
		} `json:"hide_credentials"`
		KeyNames struct {
			Default  []string `json:"default"`
			Required bool     `json:"required"`
			Type     string   `json:"type"`
		} `json:"key_names"`
	} `json:"fields"`
}
type T6 struct {
	Worker struct {
		Id    int `json:"id"`
		Count int `json:"count"`
	} `json:"worker"`
	Stats struct {
		Flamegraph struct {
			Running     string `json:"running"`
			ElapsedTime string `json:"elapsed_time"`
			Pending     string `json:"pending"`
		} `json:"flamegraph"`
		Sys struct {
			Running int `json:"running"`
			Runs    int `json:"runs"`
			Pending int `json:"pending"`
			Waiting int `json:"waiting"`
			Total   int `json:"total"`
		} `json:"sys"`
		Timers struct {
			HealthcheckLocalhost8080 struct {
				Name string `json:"name"`
				Meta struct {
					Name      string `json:"name"`
					Callstack string `json:"callstack"`
				} `json:"meta"`
				Stats struct {
					Finish      int `json:"finish"`
					Runs        int `json:"runs"`
					ElapsedTime struct {
						Min      int `json:"min"`
						Max      int `json:"max"`
						Avg      int `json:"avg"`
						Variance int `json:"variance"`
					} `json:"elapsed_time"`
					LastErrMsg string `json:"last_err_msg"`
				} `json:"stats"`
			} `json:"healthcheck-localhost:8080"`
		} `json:"timers"`
	} `json:"stats"`
}

// ## Health 健康

type KongStatusLuaSharedDicts struct {
	AllocatedSlabs string `json:"allocated_slabs"`
	Capacity       string `json:"capacity"`
}
type KongStatus struct {
	Database struct {
		Reachable bool `json:"reachable"`
	} `json:"database"`
	Memory struct {
		WorkersLuaVms []struct {
			HttpAllocatedGc string `json:"http_allocated_gc"`
			Pid             int    `json:"pid"`
		} `json:"workers_lua_vms"`
		LuaSharedDicts struct {
			Kong                     KongStatusLuaSharedDicts `json:"kong"`
			KongLocks                KongStatusLuaSharedDicts `json:"kong_locks"`
			KongHealthchecks         KongStatusLuaSharedDicts `json:"kong_healthchecks"`
			KongProcessEvents        KongStatusLuaSharedDicts `json:"kong_process_events"`
			KongClusterEvents        KongStatusLuaSharedDicts `json:"kong_cluster_events"`
			KongRateLimitingCounters KongStatusLuaSharedDicts `json:"kong_rate_limiting_counters"`
			KongCoreDbCache          KongStatusLuaSharedDicts `json:"kong_core_db_cache"`
			KongCoreDbCacheMiss      KongStatusLuaSharedDicts `json:"kong_core_db_cache_miss"`
			KongDbCache              KongStatusLuaSharedDicts `json:"kong_db_cache"`
			KongDbCacheMiss          KongStatusLuaSharedDicts `json:"kong_db_cache_miss"`
			PrometheusMetrics        KongStatusLuaSharedDicts `json:"prometheus_metrics"`
		} `json:"lua_shared_dicts"`
	} `json:"memory"`
	Server struct {
		TotalRequests       int `json:"total_requests"`
		ConnectionsActive   int `json:"connections_active"`
		ConnectionsAccepted int `json:"connections_accepted"`
		ConnectionsHandled  int `json:"connections_handled"`
		ConnectionsReading  int `json:"connections_reading"`
		ConnectionsWriting  int `json:"connections_writing"`
		ConnectionsWaiting  int `json:"connections_waiting"`
	} `json:"backend"`
	ConfigurationHash string `json:"configuration_hash"` // todo 没见到
}

// ## Status 状态

type T8 struct {
	Data []struct {
		EntityName string `json:"entity_name"`
		EntityId   string `json:"entity_id"`
		Tag        string `json:"tag"`
	} `json:"data"`
	Offset string `json:"offset"`
	Next   string `json:"next"`
}

// ## Service 服务

type T9 struct {
	Id                string   `json:"id"`
	CreatedAt         int      `json:"created_at"`
	UpdatedAt         int      `json:"updated_at"`
	Name              string   `json:"name"`
	Retries           int      `json:"retries"`
	Protocol          string   `json:"protocol"`
	Host              string   `json:"host"`
	Port              int      `json:"port"`
	Path              string   `json:"path"`
	ConnectTimeout    int      `json:"connect_timeout"`
	WriteTimeout      int      `json:"write_timeout"`
	ReadTimeout       int      `json:"read_timeout"`
	Tags              []string `json:"tags"`
	ClientCertificate struct {
		Id string `json:"id"`
	} `json:"client_certificate"`
	TlsVerify      bool        `json:"tls_verify"`
	TlsVerifyDepth interface{} `json:"tls_verify_depth"`
	CaCertificates []string    `json:"ca_certificates"`
	Enabled        bool        `json:"enabled"`
}
